#ifndef DRAWVIEW_H
#define DRAWVIEW_H

#include "roundrectitem.h"
#include "curveitem.h"

#include <QWidget>
#include <QMouseEvent>
#include <QDebug>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsItem>
#include <QFileDialog>
#include <QMessageBox>
#include <QException>
#include <QStack>
#include "qcheckbox.h"
enum Mode {empty, draw, line, curve, rectangle, roundrect, circle, ellipse, choose}; //操作模式

class DrawView : public QGraphicsView
{
    Q_OBJECT

private:
    Mode mode;

    QPointF startPos;           //点类

    int style;
    int weight;
    int w;
    int h;
    QColor color;
    QColor b_color;
    QColor recordColor[1000][1000];
    int brushCheck = 0; //0不填充 1填充
    bool addColor = false;//填充颜色
    QGraphicsScene scene;
    QSet<QGraphicsItem*> items;
    QStack<QGraphicsItem*> deleteitems; //已经删除的图像
    QStack<QGraphicsItem*> existitems;  //存在与画布上的图像
    QGraphicsItem * tempItem;

public:
    explicit DrawView(QWidget *parent);

    void setMode(Mode m);
    void addImage();
    void saveImage();
    void fillColor(int, int, QColor);
    void mouseMoveEvent(QMouseEvent *);
    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);

    void keyPressEvent(QKeyEvent*);

signals:

public slots:
    void setStyle (int);
    void setWidth (int);
    void setColor (QColor);
    void setBColor (QColor);
    void clear ();
    void undo ();
    void redo ();
    void setCheckBox (int);
    void setAddColorTag(bool);
    void setSize(int, int);
    void floodFill4(int x, int y, QColor, QColor);
    void setRecordColor(QColor, int, int);
    QColor getRecordColor(int, int);
};

#endif // DRAWVIEW_H
